import React, { useRef } from 'react'
import PubSub from "pubsub-js"
import "./HerosSearch.css"
export default function HerosSearch() {

    // 获取真实dom对象
    let input = useRef();

    //搜索方法
    let search = ()=>{
        // console.log(input.current.value);
        //获取输入框值
        let value = input.current.value;

        //发布频道  传递数据
        PubSub.publish("keyword",value);
    }

    return (
        <div className='search'>
            <input type="search" ref={input} placeholder='请输入英雄名称' />
            <button onClick={search}>搜索</button>
        </div>
    )
}
